const {
  $util,
} = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: 1,
    list: [],
    isloadmore: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData(options);
    wx.setNavigationBarTitle({
      title: options.barTitle && decodeURIComponent(options.barTitle) || '',
    });
    this.loadList();
  },
  loadList() {
    $util.request({
      url: 'entry/wxapp/edu.affairs.more',
      data: {
        type: this.data.typ,
        page: this.data.page,
      },
      success: (res) => {
        let list = this.data.list;
        list = list.concat(res.list);
        this.setData({
          list,
          isloadmore: res.total > list.length,
          page: res.total > list.length ? ++this.data.page : this.data.page,
        });
      },
    });
  },
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if (this.data.isloadmore) {
      this.loadList();
    }
  },
});
